package cn.com.open.itembank.dto;

import java.util.ArrayList;
import java.util.List;

/**
 * 试卷小题组.
 */
public class PaperItemGroup extends ItemGroup {
    /**
     * Instantiates a new Paper item group.
     */
    public PaperItemGroup() {
        super();
        this.questionStructures = new ArrayList<>();
        this.displayRates = new ArrayList<>();
    }

    /**
     * 试题列表.
     */
    private List<QuestionStructure> questionStructures;
    /**
     * The Display rates.
     */
    private List<Integer> displayRates;

    /**
     * Gets question structures.
     *
     * @return the question structures
     */
    public List<QuestionStructure> getQuestionStructures() {
        if (questionStructures == null) {
            questionStructures = new ArrayList<>();
        }

        return questionStructures;
    }

    /**
     * Gets display rates.
     *
     * @return the display rates
     */
    public List<Integer> getDisplayRates() {
        if (displayRates == null) {
            displayRates = new ArrayList<>();
        }

        return displayRates;
    }

    @Override
    public PaperItemGroup copy() {
        PaperItemGroup copy = new PaperItemGroup();

        copy.setItemGroupSerialNum(getItemGroupSerialNum());
        copy.setQuestionTypeID(getQuestionTypeID());
        copy.setQuestionCategories(getQuestionCategories());
        copy.setResponseDuration(getResponseDuration());
        copy.setRepeatInterval(getRepeatInterval());
        copy.setRepeatTimes(getRepeatTimes());

        for (String chapterId : getChapterIDs()) {
            copy.getChapterIDs().add(chapterId);
        }

        for (Double difficulty : getDifficulties()) {
            copy.getDifficulties().add(difficulty);
        }

        for (Integer displayRate : displayRates) {
            copy.displayRates.add(displayRate);
        }

        for (QuestionStructure qs : questionStructures) {
            copy.questionStructures.add(qs.copy());
        }

        return copy;
    }
}
